iT邦幫忙

2024 iThome 鐵人賽

DAY 14
0
Security

資安日誌分析系列 第 14

14. Windows 開啟惡意文件分析(Word)

  • 分享至 

  • xImage
  •  

說明

駭客常利用Email大量發送釣魚信件,當受害者點開連結或開啟Word時駭客就可以取得遠端連線到該主機的能力

作法

使用MSF生成惡意巨集Word,假設使用者已經誤點開文件
msf > use exploit/multi/fileformat/office_word_macro
https://www.rapid7.com/db/modules/exploit/multi/fileformat/office_word_macro/

EventLog

PowerShell Query

Get-WinEvent -FilterXml '
<QueryList>
  <Query Id="0" Path="Microsoft-Windows-Sysmon/Operational">
     <Select Path="Microsoft-Windows-Sysmon/Operational">
	*[System[TimeCreated[@SystemTime&gt;="2024-09-28T09:24:00.000Z" and @SystemTime&lt;="2024-09-28T09:24:07.999Z"]]]
	</Select>
	<Suppress Path="Microsoft-Windows-Sysmon/Operational">*[System[(EventID=13)]]</Suppress>
  </Query>
</QueryList>
' |
Select-Object TimeCreated, Id,
@{Name="ParentProcessId"; Expression={$_.Properties[19].Value}},
@{Name="ProcessId"; Expression={$_.Properties[3].Value}}, 
@{Name="Image"; Expression={$_.Properties[4].Value}} |
Sort-Object TimeCreated

整個Sysmon事件如下,一個個編號看做了什麼事情
https://ithelp.ithome.com.tw/upload/images/20240928/20077752jQ0utZYlxp.png

https://ithelp.ithome.com.tw/upload/images/20240928/20077752FGKe47N0Zp.png

1. WORD.EXE網路連線行為

WORD.EXE(7212)
https://ithelp.ithome.com.tw/upload/images/20240928/20077752Jd7Gnr6yqp.png

2. 建立第一個PowerShell程序

WORD.EXE(7212) > PowerShell.EXE(1612)
查看Log 從(2)Outlook路徑Word執行PowerShell,這行為非常異常,且(1)指令用base64編碼過
https://ithelp.ithome.com.tw/upload/images/20240928/20077752XbeqraTzvq.png
https://ithelp.ithome.com.tw/upload/images/20240928/20077752kOroLjY7Mt.png

使用CyberChef解碼,裡面是另一個PowerShell指令,在第二個PowerShell日誌會看到相同指令
https://ithelp.ithome.com.tw/upload/images/20240928/20077752WItCBGZ6Pp.png

3. 產生第一個PowerShell暫存檔

PowerShell.EXE(1612) > File Created .ps1
C:\Users\Administrator\AppData\Local\Temp__PSScriptPolicyTest_l1eypddw.tsz.ps1
https://ithelp.ithome.com.tw/upload/images/20240928/20077752X7EiKKAmYZ.png

4. 建立第二個PowerShell程序

WORD.EXE(7212) > PowerShell.EXE(1612) > PowerShell.EXE(6744)
https://ithelp.ithome.com.tw/upload/images/20240928/200777522VQapUYR8o.png

取出要解碼的區域[a-zA-Z0-9+/=]{30,}
https://ithelp.ithome.com.tw/upload/images/20240929/20077752jALu5kaDTM.png

再做一次解碼
https://ithelp.ithome.com.tw/upload/images/20240929/20077752KbWlcJY561.png

5. 產生第二個PowerShell暫存檔

PowerShell.EXE(1612) > File Created .ps1
C:\Users\Administrator\AppData\Local\Temp__PSScriptPolicyTest_rzonuyj0.gvi.ps1
https://ithelp.ithome.com.tw/upload/images/20240928/20077752Gfws0H5mzF.png

GPO PowerShell Audit

在GPO開啟PowerShell Transcript Logging紀錄也可以紀錄PowerShell暫存檔
https://coady.tech/setup-powershell-transcript-logging/

https://ithelp.ithome.com.tw/upload/images/20240929/20077752kNxQynlbrk.png

REF

Configure PowerShell logging to see PowerShell anomalies in Splunk UBA
https://docs.splunk.com/Documentation/UBA/5.4.1/GetDataIn/AddPowerShell

Group Policy Administrative Templates Catalog
https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.PowerShell::EnableScriptBlockLogging&Language=zh-tw

政府組態基準(GCB)
https://www.nics.nat.gov.tw/core_business/cybersecurity_defense/GCB/GCB_Documentation/

cyberchef-recipes
https://github.com/mattnotmax/cyberchef-recipes

MSF利用宏病毒感染word文档获取shell复现
https://blog.csdn.net/weixin_40228200/article/details/125240360

MSFVenom - CheatSheet
https://book.hacktricks.xyz/generic-methodologies-and-resources/reverse-shells/msfvenom

Decoding Malicious PowerShell Activity - A Case Study
https://community.sophos.com/sophos-labs/b/blog/posts/decoding-malicious-powershell

Deobfuscating Emotet’s powershell payload
https://medium.com/@ahmedjouini99/deobfuscating-emotets-powershell-payload-e39fb116f7b9

https://www.cardboard-iguana.com/grimoire/spellbook/msfvenom


上一篇
13. Windows 網站入侵分析(WordPress)-3
下一篇
15. Windows 持久化(Schedule)
系列文
資安日誌分析30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言